package com.bianmaba.spring.data.jpa.domain.specification.condition.predicate.generator;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 对字段进行单条件判断
 * Created by cwx183898 on 2017/12/17.
 */
public abstract class AbstractNonRightPredicateGenerator extends AbstractPredicateGenerator {
    @Override
    protected Predicate invokeCreate(CriteriaBuilder builder, Method method, Path path, Object data) {
        Predicate predicate = null;
        try {
            predicate = (Predicate) method.invoke(builder, path);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return predicate;
    }
}
